package com.kmxd.ams.core.common.enums;

import com.kmxd.ams.core.common.constant.ErrorCode;
import com.kmxd.ams.core.exception.BizException;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 备份类型：1全宗备份，2门类备份
 *
 * @author admin
 */
@Getter
@AllArgsConstructor
public enum BackupTypeEnum {

  /** 存在 */
  FONDS(1, "按全宗备份"),
  /** 删除 */
  ARCH_TYPE(2, "按门类备份");

  private Integer type;
  private String desc;

  public static BackupTypeEnum convert(Integer type) {
    return Arrays.stream(values())
        .filter(x -> x.type.equals(type))
        .findAny()
        .orElseThrow(() -> BizException.instance(ErrorCode.NOT_FOUND, "未找到备份类型：" + type));
  }
}
